﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BSCMFF.Core.DataAccessLayer;
using Telerik.Web.UI;
using BSCMFF.Web.UserControls.Selections;
using BSCMFF.Web.UserControls.Evaluation;

namespace BSCMFF.Web.Pages.working
{
    public partial class testingemployeeselectionbinding : BSCMFF.Core.MultiLanguagePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //BSCEntities context = new BSCEntities();
            //List<User> users = (from u in context.Users.Include("SBU")
            //                    select u).ToList();

            //foreach (User u in users)
            //{
            //    AssignEmployeeEvaluator aee = LoadControl("~/UserControls/Evaluation/AssignEmployeeEvaluator.ascx") as AssignEmployeeEvaluator;

            //    aee.Employee = u;
            //    aee.DataBind();

            //    //TableEmployees.Rows.Add(aee);

            //    PlaceHolderEmployees.Controls.Add(aee);

            //}


            fill();
            //if (Session["moore"] != null)
            //{
            //    List<User> users = (List<User>)Session["moore"];

            //    RadGrid1.DataSource = users;
            //    RadGrid1.DataBind();
            //}
        }

        private void fill()
        {
            BSCEntities context = new BSCEntities();

            //List<User> users = (from eu in context.Evaluation_User.Include("User.SBU")
            //                    where eu.User_FK == 26
            //                    select eu.User).ToList();

            List<User> users = (from u in context.Users
                                where u.ID == 5
                                select u).ToList();

            //RadGrid1.Dispose();
            RadGrid1.DataSource = users;
            
            RadGrid1.DataBind();


           // Session.Add("moore", users);

            //RadGrid1.PreRender += new EventHandler(RadGrid1_PreRender);

        }

        //void RadGrid1_PreRender(object sender, EventArgs e)
        //{
        //    ((RadGrid)sender).Rebind();
        //}

        protected void b_Click(object sender, EventArgs e)
        {
            //RadGrid rg = new RadGrid();
            //rg.ID = "rg";
            ////rg.MasterTableView = new GridTableView();

            //GridTemplateColumn gc = new GridTemplateColumn();
            ////gc.ItemTemplate = new MyTemplate


            //MenuItemTemplateContainer template = new MenuItemTemplateContainer(0, null);

            //EmployeeSimpleSelection ess = Page.LoadTemplate("~/UserControls/Selections/EmployeeSimpleSelection.ascx") as EmployeeSimpleSelection;
            //ess.ID = "newess";
            //ess.SelectedUserID = 5;// (int?)Eval("Manager_FK");
            //template.Controls.Add(ess);

            //ITemplate it = Page.LoadTemplate("~/UserControls/Selections/EmployeeSimpleSelection.ascx");
            
            //((EmployeeSimpleSelection)it).SelectedUserID = 5;

            //gc.ItemTemplate = it;

            //RadGrid1.MasterTableView.Columns.Add(gc);

            //rg.MasterTableView.Columns.Add(gc);
            //rg.AutoGenerateColumns = false;
            //PlaceHolderGrid.Controls.Add(rg);

            fill();

            //BSCEntities context = new BSCEntities();

            //List<User> users = (from eu in context.Evaluation_User.Include("User.SBU")
            //                    where eu.Evaluation_FK == 28
            //                    select eu.User).ToList();

            //rg.DataSource = users;
           // rg.DataBind();
        }

        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            //if (e.Item is GridDataItem)
            //{
            //    GridDataItem dataItem = e.Item as GridDataItem;
            //    int fieldValue = int.Parse(dataItem[.Text);
            //    if (eeeID == fieldValue)
            //    {
            //        e.Item.Selected = true;
            //        //RadGridEvaluatedEmployees.SelectedValue = eeeID;
            //    }
            //}
        }

        

        
    }
}